package com.chengzzz.mysite.result;


import com.chengzzz.mysite.entity.User;
import com.chengzzz.mysite.enums.ResultEnum;
import com.chengzzz.mysite.pojo.UserPojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @program: myfunhome
 * @description: 返回数据类型

 * @create: 2020-06-18 22:55
 **/



@Data
public class Result<T>  implements Serializable {

    private Integer code;
    private String msg;
    private T data;
    private T stats;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public T getStats() {
        return stats;
    }

    public void setStats(T stats) {
        this.stats = stats;
    }

    public Result(Integer code, String msg, T data, T stats) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.stats = stats;
    }

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result() {
    }

    /**
     * 返回成功的类型
     * @param data
     */
    public Result(T data, String msg) {
        this.code= ResultEnum.SUCCESS.getCode();
        this.data = data;
        this.msg=msg;
    }

    public Result(String msg) {
        this.code= ResultEnum.SUCCESS.getCode();
        this.msg = msg;
    }

    public Result(T data) {
        this.code= ResultEnum.SUCCESS.getCode();
        this.msg=ResultEnum.SUCCESS.getMsg();
        this.data = data;
    }
}
